﻿using Hotel_Project.Bean;
using Hotel_Project.Tools.MySqlData_Helps;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Hotel_Project.BIZ
{
    internal class GuestInfoBIZ
    {
        /// <summary>
        /// 对客人进行mysql数据库表的登录 增加
        /// </summary>
        /// <param name="guest"></param>
        /// <returns></returns>
        public int Add(GuestInfo guest)
        {
            string sql = "insert into guestinfo (g_Name,Sex,Id_card,Address,Telephone,Remark,room_number) values (@g_Name,@Sex,@Id_card,@Address,@Telephone,@Remark,room_number)";
            MySQLHelper.PrepareMySql(sql);
            MySQLHelper.SetParameters("g_Name", guest.Name);
            MySQLHelper.SetParameters("Sex", guest.Sex);
            MySQLHelper.SetParameters("Id_card", guest.IDCard);
            MySQLHelper.SetParameters("Address", guest.Address);
            MySQLHelper.SetParameters("Telephone", guest.Phone);
            MySQLHelper.SetParameters("Remark", guest.Remark);
            MySQLHelper.SetParameters("room_number", guest.Room_number);
            return MySQLHelper.ExecuteNonQuery();

        }
        /// <summary>
        /// 对客人的联系方式进行删除操作
        /// </summary>
        /// <param name="name"></param>
        /// <param name="phone"></param>
        /// <returns></returns>
        public int Delete(string name, int phone)
        {
            string sql = "delete from guestinfo where g_Name=@g_Name and Telephone=@Telephone";
            MySQLHelper.PrepareMySql(sql);
            MySQLHelper.SetParameters("g_Name", name);
            MySQLHelper.SetParameters("Telephone", phone);
            return MySQLHelper.ExecuteNonQuery();
        }
    }
}
